import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class BDManagement {
	private final static String drv="org.postgresql.Driver";
	private final static String db="jdbc:postgresql://localhost:5432/Laboratorio";
	private final static String user="postgres"; 
	private final static String pas="antisocial"; 	
	private Connection ct;
	private Statement st=null	;

	public BDManagement(){
		try{
			Class.forName(drv);
			ct=DriverManager.getConnection(db,user,pas);
			st=ct.createStatement();//instanciar al statement para poder hacer consultas
			System.out.println("conexion exitosa");			
		}catch(Exception e){
			System.err.println("no se pudo conectar a la base de datos");			
		}
	}
	public void ShowAll(){
		try{
			ResultSet rs =st.executeQuery("SELECT * FROM Persona");
			while(rs.next())
				System.out.println(rs.getString(1)+"|"+rs.getString(2)+"|"+rs.getString(3)+"|"+rs.getString(4));
				
			
		}catch(Exception e){
			System.err.println("error al ejecutar la consulta");
			
		}
	}
	public Statement getSt(){
		return st;
	}	

}
